package jsyf.oa.web.report;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.capital.CapitalFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List;

@Api(value = "资金日报表一级报表", description = "资金日报表一级报表")
@Controller
@RequestMapping("/reportCapital")
public class CapitalReportController {

    @Resource
    private CapitalFacade capitalFacade;

    @RequestMapping(value = "/getCapitalTotal.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "资金日报表一级",
            notes = "资金日报表",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    public void getWechatShareTotal(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject obj = JSON.parseObject(jsonData);
        String date = obj.getString("date");
        List<JSONObject> result = this.capitalFacade.getCapitalTotal(jsonData, date);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(result));
    }

    @RequestMapping(value = "/getFundsTotal.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "资金日报表卡片",
            notes = "资金日报表",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    public void getFundsTotal(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = this.capitalFacade.getFundsTotal();
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(result));
    }
}
